package kandl.automation.steprunner.selenium.commands;

import kandl.automation.steprunner.selenium.Command;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;

@Component
class ScrollToElement1 implements Command {
    @Override
    public void runCommand(WebDriver driver, String... params) {
        JavascriptExecutor js = (JavascriptExecutor) driver;
		js.executeScript("window.scrollBy(0, 400)");
		driver.findElement(By.xpath(params[0])).click();
    }

    @Override
    public String getName() {
        return "scrollToElement1";
    }
}
